home *** CD-ROM | disk | FTP | other *** search
/ Aminet 37 / Aminet 37 (2000)(Schatztruhe)[!][Jun 2000].iso / Aminet / dev / src / emog.lha / tools.e < prev   
Encoding:
Text File  |  2000-03-07  |  3.0 KB  |  109 lines

  1. /* -- ----------------------------------------------------- -- *
  2.  * -- Name........: tools.e                                 -- *
  3.  * -- Description.: Simple collection of helpful functions. -- *
  4.  * -- Author......: Daniel Kasmeroglu                       -- *
  5.  * -- E-Mail......: raptor@cs.tu-berlin.de                  -- *
  6.  * --               daniel.kasmeroglu@daimlerchrysler.com   -- *
  7.  * -- Date........: 05-Mar-00                               -- *
  8.  * -- Version.....: 0.1                                     -- *
  9.  * -- ----------------------------------------------------- -- */
  10.  
  11. /* -- ----------------------------------------------------- -- *
  12.  * --                         Options                       -- *
  13.  * -- ----------------------------------------------------- -- */
  14.  
  15. OPT MODULE
  16. OPT EXPORT
  17.  
  18.  
  19. /* -- ----------------------------------------------------- -- *
  20.  * --                       Declarations                    -- *
  21.  * -- ----------------------------------------------------- -- */
  22.  
  23. DEF dec_state
  24.  
  25.  
  26. /* -- ----------------------------------------------------- -- *
  27.  * --                         Functions                     -- *
  28.  * -- ----------------------------------------------------- -- */
  29.  
  30. ->> PROC getTempFile
  31. ->
  32. -> SPEC   getTempFile( buffer )
  33. -> DESC   Fills the supplied buffer with a path
  34. ->        that may be used for temporarily access.
  35. -> PRE    {buffer} : A valid path of something around 15 characters.
  36. -> POST   true
  37. ->
  38. PROC getTempFile( get_file )
  39. DEF get_temp [ 20 ] : STRING
  40. DEF get_num
  41.  
  42.   get_num := 1
  43.   REPEAT
  44.     StringF( get_temp, 't:tfile.\d', get_num )
  45.     get_num := get_num + 1
  46.   UNTIL FileLength( get_temp ) < 1
  47.  
  48.   AstrCopy( get_file, get_temp, 20 )
  49.  
  50. ENDPROC
  51. -><
  52.  
  53. ->> PROC writeFile
  54. ->
  55. -> SPEC   writeFile( destpath, buffer, bufflen ) = noerr
  56. -> DESC   Stores the contents of a buffer under a specified path.
  57. -> PRE    {destpath} : Path where to store the contents. This function
  58. ->                     doesn't check if there is already a file present.
  59. ->        {buffer}   : Valid buffer containing our data.
  60. ->        {bufflen}  : Length of the buffer or length of the data to store.
  61. -> POST   noerr <=> FileLength( {destpath} ) == {bufflen}
  62. ->
  63. PROC writeFile( wri_dest, wri_mem, wri_len )
  64. DEF wri_handle,wri_written
  65.  
  66.   wri_handle  := Open( wri_dest, NEWFILE )
  67.   IF wri_handle = NIL THEN RETURN FALSE
  68.  
  69.   wri_written := Write( wri_handle, wri_mem, wri_len )
  70.   Close( wri_handle )
  71.  
  72. ENDPROC wri_written = wri_len
  73. -><
  74.  
  75. ->> PROC displayGauge
  76. ->
  77. -> SPEC   displayGauge()
  78. -> DESC   Stupid function to realise a simple gauge. For bigger
  79. ->        files it lets the user know that the app is running and not dead.
  80. -> PRE    true
  81. -> POST   true
  82. ->
  83. PROC displayGauge()
  84.  
  85.   WriteF( '\c', 13 )
  86.  
  87.   SELECT dec_state
  88.   CASE  00 ; WriteF( '|'  )
  89.   CASE  30 ; WriteF( '/'  )
  90.   CASE  60 ; WriteF( '-'  )
  91.   CASE  90 ; WriteF( '\\' )
  92.   CASE 120 ; WriteF( '|'  )
  93.   CASE 150 ; WriteF( '/'  )
  94.   CASE 180 ; WriteF( '-'  )
  95.   CASE 210 ; WriteF( '\\' )
  96.   ENDSELECT
  97.  
  98.   dec_state := dec_state + 1
  99.  
  100.   IF dec_state = 240
  101.     dec_state := 0
  102.   ENDIF
  103.  
  104. ENDPROC
  105. -><
  106.  
  107.  
  108.  
  109.